package room_event

import (
	"longmen/server/internal/rpc/tencentim/api"
	"longmen/server/internal/rpc/tencentim/chat"
	messages2 "longmen/server/internal/rpc/tencentim/messages"
	"longmen/server/internal/rpc/tencentim/utils"
	pb "longmen/server/pkg/protobuf"
)

func handlingLoveMessage(c *chat.ClientUser, _ []byte) (ret *pb.CallbackResp, err error) {
	rep := &messages2.LoveReplyMessage{}
	rep.Type = messages2.LoveReplyMessageType

	fansNum, err := api.GetAPI().ToggleAttentionAnchor(c.RoomId, c)
	if err != nil {
		rep.Code = 1
		rep.Message = err.Error()
		return utils.CallbackFailResp(rep, err.Error()), err
	}
	rep.Data.FansNum = fansNum.FansCount

	return utils.CallbackOkResp(&messages2.RoomUserLoveMessage{
		SentMessageStruct: messages2.SentMessageStruct{Type: messages2.RoomUserLoveMessageType},
	}), nil

}
